import Taro from '@tarojs/taro'

import {
  LOADDATA
} from '../constants/list'

export const loadDataSync = (list) => {
  return {
    type: LOADDATA,
    list
  }
}

// 异步的action
export function loadDataAsync () {
  return dispatch => {
    Taro.request({
      url: 'http://localhost:9000/list',
      success: (result) => {
        dispatch(loadDataSync(result.data.data))
      }
    })
  }
}
